package com.zzjson.schedule;

import com.zzjson.job.HelloJob;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;


/**
 * <p>****************************************************************************</p>
 * <p><b>Copyright © 2010-2019 shuncom team All Rights Reserved<b></p>
 * <ul style="margin:15px;">
 * <li>Description : com.zzjson.example.quartz</li>
 * <li>Version     : 1.0.0</li>
 * <li>Creation    : 2019年12月04日</li>
 * <li>@author     : zzy0_0</li>
 * </ul>
 * <p>****************************************************************************</p>
 */
public class MyScheduler {

	public static void main(String[] args) {

		try {
			//设置jobData
			JobDetail job = JobBuilder.newJob(HelloJob.class)
					.withIdentity("job1", "group1")
					.usingJobData("my-name", "zzy")
					.build();

			Trigger trigger = TriggerBuilder.newTrigger()
					.withIdentity("trigger1", "group1")
					.startNow()
					.withSchedule(
							SimpleScheduleBuilder
									.simpleSchedule()
									.withIntervalInSeconds(3)
									.repeatForever()).build();


			Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
			scheduler.scheduleJob(job, trigger);
			scheduler.start();


		} catch (SchedulerException se) {
			se.printStackTrace();
		}
	}
}